import request from './request'

/**
 * 全局搜索
 * @param {Object} params
 * @param {string} params.keyword - 搜索关键词
 * @param {string} params.type - 搜索类型 (all/product/service)
 * @param {number} params.page - 页码
 * @param {number} params.size - 每页大小
 * @returns {Promise}
 */
export function globalSearch(params) {
  return request({
    url: '/search',
    method: 'get',
    params
  })
}

/**
 * 获取搜索建议
 * @param {Object} params
 * @param {string} params.keyword - 搜索关键词
 * @returns {Promise}
 */
export function getSearchSuggestions(params) {
  return request({
    url: '/search/suggest',
    method: 'get',
    params
  })
}

/**
 * 获取热门搜索
 * @param {Object} params
 * @param {number} params.limit - 返回数量
 * @returns {Promise}
 */
export function getHotSearches(params) {
  return request({
    url: '/search/hot',
    method: 'get',
    params
  })
}

/**
 * 获取搜索历史
 * @returns {Promise}
 */
export function getSearchHistory() {
  return request({
    url: '/search/history',
    method: 'get'
  })
}

/**
 * 清除搜索历史
 * @returns {Promise}
 */
export function clearSearchHistory() {
  return request({
    url: '/search/history',
    method: 'delete'
  })
}
